'''
Created on Dec 8, 2015

@author: JimmyMo
'''
import unittest
from locator import Locator
from collector import FilePathCollector
from collector import FileNameCollector
from collector import RegularExpressionCollector
import ruleprocessor

class TestCollector(unittest.TestCase):
    locators = []
    @classmethod
    def setUpClass(cls):
        locatorMovie = Locator(enabled=True, name="movieLocator", locationPath="/home/JimmyMo/git/resourcecare/resourcecare/testres/07.Movies", includeType="_folder_")
        locatorCartoon = Locator(enabled=True, name="cartoonLocator", locationPath="/home/JimmyMo/git/resourcecare/resourcecare/testres/06.Cartoons", includeType="_folder_")
        TestCollector.locators.append(locatorMovie)
        TestCollector.locators.append(locatorCartoon)
        
    @classmethod
    def tearDownClass(cls):
        pass
    
    def setUp(self):
        pass
    
    def tearDown(self):
        pass
    
    def test_filepath_collector_with_two_locators(self):
        print("start test_filepath_collector_with_two_locators...")
        collector = FilePathCollector(enabled=True, 
                                      name="filepathCollector", 
                                      desc="this is desc...", 
                                      locators=TestCollector.locators)
        results = collector.do_collect()
        print ("\n".join(results))
        self.assertEqual(7, len(results))
        
    def test_filename_collector(self):
        print("start test_filename_collector...")
        collector = FileNameCollector(enabled=True, 
                                      name="filenameCollector", 
                                      desc="this is desc...", 
                                      locators=TestCollector.locators)
        results = collector.do_collect()
        print ("\n".join(results))
        self.assertEqual(7, len(results))
    
    def test_regEx_collector(self):
        print("start test_regEx_collector...")
        ruleProcessor = ruleprocessor.getRuleProcessor("RegexRuleProcessor", "720p")
        collector = RegularExpressionCollector(enabled=True, 
                                               name="regexCollector", 
                                               parentCollectorName="FileNameCollector", 
                                               desc="this is desc...", 
                                               locators=TestCollector.locators, 
                                               ruleProcessor=ruleProcessor)
        results = collector.do_collector()
        print ("\n".join(results))
        
if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    unittest.main()